package threadlocal

import org.junit.Test

class ThreadLocalDemo {

    @Test
    fun testThreadLocal() {

        val threadLocal = ThreadLocal<Int>()
        threadLocal.set(6)

        Thread {
            println("获取父线程中的数据11:${threadLocal.get()}")
        }.start()

        println("fun testThreadLocal()")
    }

    @Test
    fun testThreadLocal2() {

        val threadLocal = InheritableThreadLocal<Int>()
        threadLocal.set(6)

        Thread {
            println("获取父线程中的数据22:${threadLocal.get()}")
        }.start()

        println("fun testThreadLocal2()")
    }

}